package cn.bugstack.springframework.test.bean;



import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;


/**
 * @author Yaxi.Zhang
 * @since 2022/12/22 18:36
 */
public class UserServiceInterceptor implements MethodInterceptor {

    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
        long start = System.currentTimeMillis();
        Object proceed = invocation.proceed();
        System.out.println("监控 - Begin By AOP");
        System.out.println("方法名称：" + invocation.getMethod());
        System.out.println("方法耗时：" + (System.currentTimeMillis() - start) + "ms");
        System.out.println("监控 - End\r\n");
        return proceed;
    }

}
